# 编译器和编译选项(优化选项 O2 或 O3，根据具体需要来)  
CC = gcc  
CFLAGS = -Wall -g -O3 -std=gnu99
  
# 设置源文件目录和目标文件目录
SRCDIR = ./src
# 查找所有 .c 文件，并将路径存储到 SRC 变量
SRC = $(shell find $(SRCDIR) -name '*.c')

# 依赖库列表（以空格分隔）  
LIBS = -lpthread -lssl

# 程序入口
MAIN = linux_tools.c

# 设置生成可执行文件的名称和路径
TARGET = ./bin/linux_tools

all:
	$(CC) $(CFLAGS) $(MAIN) $(SRC) -o $(TARGET) $(LIBS) -g

install:
	mkdir -p /usr/local/linux_tools;
	cp -r bin/* /usr/local/linux_tools;
	chmod +x /usr/local/linux_tools/linux_tools;
	chmod +x /usr/local/linux_tools/shell/*.sh;

	@if [ -e /bin/lt ]; then \
		echo "ERROR: File Conflict with /bin/lt"; \
		exit 1;\
	else \
		ln -s /usr/local/linux_tools/linux_tools /bin/lt; \
	fi

uninstall:
	rm -rf /usr/local/linux_tools;
	rm -rf /var/log/linux_tools;
	rm /bin/lt;
